home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / RIncludes / CodeFragments.r < prev    next >
Encoding:
Text File  |  2000-04-12  |  9.6 KB  |  262 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        CodeFragments.r
  3.  
  4.      Contains:    Public Code Fragment Manager Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8.1
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    © 1992-1999 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17.  
  18. #ifndef __CODEFRAGMENTS_R__
  19. #define __CODEFRAGMENTS_R__
  20.  
  21. #ifndef __CONDITIONALMACROS_R__
  22. #include "ConditionalMacros.r"
  23. #endif
  24.  
  25.  
  26. /*
  27.     The 'cfrg' resource serves to inform the Process Manager and Code Fragment Manager
  28.     of code fragments present in this file.
  29.     
  30.     The 'cfrg' resource must have an ID of 0.  There can only be one 'cfrg' resource
  31.     per file, however, the trailing part of a 'cfrg' resource is an array of entries.
  32.     Each entry can be used to associate a name and architecture type to a specified 
  33.     code fragment. The names are used when the system searches for code fragments as 
  34.     named shared libraries.  There can be more than one cfrg array entry per code 
  35.     fragment, this is used to give a single code fragment more than one name.
  36.  
  37.     For Applications
  38.        The 'cfrg' is required to inform the Process Manager that there is a 
  39.        code fragment available.  One of the entries which has the architecture
  40.        type appropriate for the given machine (ie: pwpc, or m68k) should have the 
  41.        kIsApp usage designation.  The Process Manager will choose this code fragment 
  42.        over the traditional CODE 0.  The location of the code fragment (usually in 
  43.        the data fork) is described within the cfrg array entry.  
  44.        
  45.        For applications, the name is important only when an application has by name 
  46.        call backs, that is, exports for drop in extensions that import from the 
  47.        application.  Generally speaking, the name of the application is used for 
  48.        its 'cfrg' array entry.
  49.        
  50.     For Shared Libraries
  51.        The 'cfrg' is required to allow the Code Fragment Manager to find shared 
  52.        libraries. 
  53.        
  54.        Shared Libraries are libraries that satisfy link time imports, that are 
  55.        usually placed in the extensions folder; they are automatically connected to 
  56.        by the Code Fragment Manager at application launch time.  Shared Libraries
  57.        must have the file type 'shlb'.  The usage field is set to kIsLib for shared 
  58.        libraries.
  59.  
  60.  
  61.     Plug-in extensions (code fragments packaged in various application specific ways)
  62.     are that loaded programaticallly by the application do not require the file type 
  63.     'shlb' and a cfrg resource, but may use some similar mechanism that is application
  64.     specific and developer defined.
  65.  
  66.  
  67.     There are two versions of the 'cfrg' resource template.
  68.  
  69.     The original version (cfrg_RezTemplateVersion = 0) is appropriate for 
  70.     applications and most shared libraries.
  71.     
  72.     The second version (cfrg_RezTemplateVersion = 1) is needed only when the code 
  73.     fragment will be found using the new CFM/SOM search mechanisms. It
  74.     contains additional information.
  75.     
  76.     In order to mix both kinds of entries in one 'cfrg' resources, the second
  77.     version of the template contains a switch statement for specifying which
  78.     kind of entry is being generated.  The following example shows how to 
  79.     convert a cfrg_RezTemplateVersion=0 format to a cfrg_RezTemplateVersion=1
  80.     format 'cfrg' resource:            
  81.  
  82.  
  83.     When cfrg_RezTemplateVersion=0 use:
  84.     
  85.                 resource 'cfrg' (0) {
  86.                     {
  87.                         kPowerPCCFragArch, kIsCompleteCFrag, kNoVersionNum, kNoVersionNum,
  88.                         kDefaultStackSize, kNoAppSubFolder,
  89.                         kApplicationCFrag, kDataForkCFragLocator, kZeroOffset, kCFragGoesToEOF,
  90.                         "My Application",
  91.                     }
  92.                 };
  93.                 
  94.     when cfrg_RezTemplateVersion=1 use:
  95.                 resource 'cfrg' (0) {
  96.                     {
  97.                         regularEntry {        // <--- add this line     
  98.                             kPowerPCCFragArch, kIsCompleteCFrag, kNoVersionNum, kNoVersionNum,
  99.                             kDefaultStackSize, kNoAppSubFolder,
  100.                             kApplicationCFrag, kDataForkCFragLocator, kZeroOffset, kCFragGoesToEOF,
  101.                             "My Application",
  102.                         }                    // <--- and this line 
  103.                     }
  104.                 };
  105.                 
  106.     The compiled binary resource is identical.
  107.     
  108.     The extended form allows specification of an OSType and 4 Str255s that are 
  109.     used as criterea in searching for libraries that satisfy some contstraints.
  110.     For example, a SOM class library that is a particular sub-class of the 
  111.     "ClassXYZ" base class, might be represented as :
  112.                 resource 'cfrg' (0) {
  113.                     {
  114.                         extendedEntry {
  115.                             kPowerPCCFragArch, kIsCompleteCFrag, kNoVersionNum, kNoVersionNum,
  116.                             kDefaultStackSize, kNoAppSubFolder,
  117.                             kImportLibraryCFrag,kOnDiskFlat,kZeroOffset,kCFragGoesToEOF,
  118.                             "MyLibName",    // standard internal name: used by CFM 
  119.                             // start of extended info 
  120.                             kFragSOMClassLibrary,
  121.                             "ClassXYZ",
  122.                             "",
  123.                             "",
  124.                             "My Name"        // external name: may be seen by user 
  125.                         }
  126.                     }
  127.                 };
  128.     Using the new CFM/SOM search functions, one could search for all som
  129.     class libraries that inherit from "ClassXYZ".
  130. */
  131.  
  132.  
  133. /*---------------------------cfrg • CodeFragments---------------------------*/
  134. /*
  135.     cfrg_RezTemplateVersion:
  136.         0 - original                         <-- default
  137.         1 - extended for SOM 
  138. */
  139. #ifndef cfrg_RezTemplateVersion
  140.     #ifdef UseExtendedCFRGTemplate                            /* grandfather in use of “UseExtendedCFRGTemplate” */
  141.         #define cfrg_RezTemplateVersion 1
  142.     #else
  143.         #define cfrg_RezTemplateVersion 0
  144.     #endif
  145. #endif
  146.  
  147.  
  148. /* grandfather in old names for fields */
  149. #define kIsLib                 kImportLibraryCFrag
  150. #define kIsApp                 kApplicationCFrag
  151. #define kIsDropIn             kDropInAdditionCFrag
  152. #define kInMem                 kMemoryCFragLocator
  153. #define kOnDiskFlat         kDataForkCFragLocator
  154. #define kOnDiskSegmented     kResourceCFragLocator
  155. #define kPowerPC             kPowerPCCFragArch
  156. #define kMotorola             kMotorola68KCFragArch
  157. #define kFullLib             kIsCompleteCFrag
  158. #define kUpdateLib             kFirstCFragUpdate
  159. #define kWholeFork             kCFragGoesToEOF
  160.  
  161.  
  162. type 'cfrg' {
  163.    longint = 0;            /* reserved - in use */
  164.    longint = 0;            /* reserved - in use */
  165.    longint = 1;            /* cfrgVersion       */
  166.    longint = 0;            /* reserved - in use */
  167.    longint = 0;            /* reserved - in use */
  168.    longint = 0;            /* reserved - free   */
  169.    longint = 0;            /* reserved - free   */
  170.    longint = $$CountOf (memberArray);
  171.    Array memberArray {
  172.      memberStart:
  173.       align long;
  174.       
  175. #if cfrg_RezTemplateVersion == 1
  176.       switch{
  177.       case regularEntry:
  178. #endif    
  179.         literal longint archType, kPowerPCCFragArch = 'pwpc', kMotorola68KCFragArch = 'm68k';
  180.         longint         updateLevel, kIsCompleteCFrag = 0, kFirstCFragUpdate = 1;
  181.         hex longint     currentVersion, kNoVersionNum = 0;
  182.         hex longint     oldDefVersion, kNoVersionNum = 0;
  183.         longint         appStackSize, kDefaultStackSize = 0;
  184.         integer         appSubFolderID, kNoAppSubFolder = 0;
  185.         byte            usage, kImportLibraryCFrag = 0, kApplicationCFrag = 1, 
  186.                             kDropInAdditionCFrag = 2, kStubLibraryCFrag = 3, 
  187.                             kWeakStubLibraryCFrag = 4;
  188.         byte            where, kMemoryCFragLocator = 0, kDataForkCFragLocator = 1, 
  189.                             kResourceCFragLocator = 2;
  190.         longint         offset, kZeroOffset = 0, kRSEG = 'rseg';
  191.         longint         length, kCFragGoesToEOF = 0, kSegIDZero = 0;
  192.         longint         = 0;      /* reserved - free */
  193. #if cfrg_RezTemplateVersion == 1
  194.         integer         = 0;      /* reserved - free */
  195.         key integer     = 0;      /* no cfrg extensions */
  196. #else
  197.         longint         = 0;      /* reserved - free   */
  198. #endif
  199.         integer         = (memberEnd[$$ArrayIndex(memberArray)] - memberStart[$$ArrayIndex(memberArray)]) / 8;
  200.         pstring;        /* member name */
  201.  
  202.  
  203. #if cfrg_RezTemplateVersion == 1
  204.       case extendedEntry:
  205.         literal longint archType, kPowerPCCFragArch = 'pwpc', kMotorola68KCFragArch = 'm68k';
  206.         longint         updateLevel, kIsCompleteCFrag = 0, kFirstCFragUpdate = 1;
  207.         hex longint     currentVersion, kNoVersionNum = 0;
  208.         hex longint     oldDefVersion, kNoVersionNum = 0;
  209.         longint         appStackSize, kDefaultStackSize = 0;
  210.         integer         appSubFolderID, kNoAppSubFolder = 0;
  211.         byte            usage, kImportLibraryCFrag = 0, kApplicationCFrag = 1, 
  212.                             kDropInAdditionCFrag = 2, kStubLibraryCFrag = 3, 
  213.                             kWeakStubLibraryCFrag = 4;
  214.         byte            where, kMemoryCFragLocator = 0, kDataForkCFragLocator = 1, 
  215.                                 kResourceCFragLocator = 2;
  216.         longint         offset, kZeroOffset = 0, kRSEG = 'rseg';
  217.         longint         length, kCFragGoesToEOF = 0, kSegIDZero = 0;
  218.         longint         = 0;      /* reserved - free */
  219.         integer         = 0;      /* reserved - free */
  220.         key integer     = 1;      /* one extension   */
  221.         integer         = (memberEnd[$$ArrayIndex(memberArray)] - memberStart[$$ArrayIndex(memberArray)]) / 8;
  222.         pstring;        /* member name */
  223.         align long;     /* match size to C structure size */
  224.         extensionStart: 
  225.         integer          = 0x30ee;       /* magic # signifies this extended cfrg entry format */
  226.         integer         = (extensionEnd[$$ArrayIndex(memberArray)] - extensionStart[$$ArrayIndex(memberArray)]) / 8;
  227.         literal longint libKind, 
  228.                     kFragDocumentPartHandler     = 'part',
  229.                     kFragSOMClassLibrary         = 'clas',
  230.                     kFragInterfaceDefinition     = 'libr',
  231.                     kFragComponentMgrComponent    = 'comp';
  232.                     /* others allowed, need to be a DTS registered OSType */
  233.         pstring;          /* qualifier 1: 
  234.                             'part' : part handler type
  235.                             'clas' : base class name
  236.                             'libr' : interface definition name
  237.                             'comp' : component kind
  238.                       */
  239.  
  240.  
  241.         pstring;          /* qualifier 2:
  242.                             'part' : part handler sub type ?
  243.                             'clas' : not used
  244.                             'libr' : not used
  245.                             'comp' : component sub kind
  246.                       */
  247.         pstring;          /* infoStr, optional information depending on libKind */
  248.         pstring;          /* intlName, an internationalizable string that can
  249.                          be displayed to the user on the screen */
  250.         align long;
  251.        extensionEnd:
  252.       };
  253. #endif
  254.      align long;
  255.      memberEnd:
  256.    };
  257. };
  258.  
  259.  
  260. #endif /* __CODEFRAGMENTS_R__ */
  261.  
  262.